package com.wanxi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wanxi.dto.ResultDto;
import com.wanxi.model.UserModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author Li
 * @Date 2023/7/6 15:04
 */
@Mapper
public interface UserMapper extends BaseMapper<UserModel> {
    /**
     * 登录查找用户名和密码是否匹配
     * @param userModel
     * @return
     */
    @Select("select * from user where username = #{username} and password = #{password}")
    UserModel findNameAndPass(UserModel userModel);

    @Select("select * from user where username = #{username} ")
    UserModel findByName(String username);
    /**
     * 查询用户名是否相同
     * @param model
     * @return
     */
    @Select("select * from user where username = #{username}")
    UserModel findSameName(UserModel model);

    @Select("select  * from user where phone = #{phone} ")
    UserModel findSamePhone(UserModel userModel);

    @Select("select * from  user where email = #{email} ")
    UserModel findSameEmail(UserModel userModel);
    /**
     * 修改密码
     * @param userModel
     * @return
     */
    @Update("update user set password = #{password} where id = #{id} ")
    Integer updatePassword(UserModel userModel);

    /**
     * 重置密码
     * @param userModel
     * @return
     */
    @Update("update user set password='4QrcOUm6Wau+VuBX8g+IPg==' where id=#{id}")
    Integer resetPassword(UserModel userModel);


}
